using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;

//创建时间：2025-11-24
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// 班次管理
    /// </summary>
    [Verify]
    [Route("business/CksBasShift")]
    [ApiExplorerSettings(GroupName = "business")]
    public class CksBasShiftController : BaseController
    {
        /// <summary>
        /// 班次管理接口
        /// </summary>
        private readonly ICksBasShiftService _CksBasShiftService;

        public CksBasShiftController(ICksBasShiftService CksBasShiftService)
        {
            _CksBasShiftService = CksBasShiftService;
        }

        /// <summary>
        /// 查询班次管理列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "cksbasshift:list")]
        public IActionResult QueryCksBasShift([FromQuery] CksBasShiftQueryDto parm)
        {
            var response = _CksBasShiftService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询班次管理详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "cksbasshift:query")]
        public IActionResult GetCksBasShift(int Id)
        {
            var response = _CksBasShiftService.GetInfo(Id);
            
            var info = response.Adapt<CksBasShiftDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加班次管理
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "cksbasshift:add")]
        [Log(Title = "班次管理", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCksBasShift([FromBody] CksBasShiftDto parm)
        {
            var modal = parm.Adapt<CksBasShift>().ToCreate(HttpContext);

            var response = _CksBasShiftService.AddCksBasShift(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新班次管理
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "cksbasshift:edit")]
        [Log(Title = "班次管理", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCksBasShift([FromBody] CksBasShiftDto parm)
        {
            var modal = parm.Adapt<CksBasShift>().ToUpdate(HttpContext);
            var response = _CksBasShiftService.UpdateCksBasShift(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除班次管理
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "cksbasshift:delete")]
        [Log(Title = "班次管理", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCksBasShift([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_CksBasShiftService.Delete(idArr));
        }

    }
}